/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.aeso.betabit.dao;

import br.aeso.betabit.entity.Aposta;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;

/**
 *
 * @author Edson
 */
public class ApostaDao extends AbstractDao<Aposta> {

    @Override
    public List<Aposta> consultar() {
        EntityManager manager = null;
		try {
			manager = factory.createEntityManager();
			CriteriaBuilder builder = manager.getCriteriaBuilder();
			CriteriaQuery<Aposta> criteria = builder.createQuery(Aposta.class);
			Root<Aposta> categoria = criteria.from(Aposta.class);
			criteria.select(categoria);
			TypedQuery<Aposta> query = manager.createQuery(criteria);
			List<Aposta> result = query.getResultList();
			return result;
		} finally {
			manager.close();
		}
    }
}
